﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Domain.Entities.Auditing;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sunlit.House.Regions;
using Sunlit.House.Floors;
using System.ComponentModel;
using Sunlit.House.Authorization.Users;
using Abp.Domain.Entities;

namespace Sunlit.House.Buy
{
    /// <summary>
    /// 团购
    /// </summary>
    [Table("AbpGroupBuys")]
    public class GroupBuy: AuditedEntity<long>, IPassivable
    {
        public long GroupBuyTypeId { get; set; }
        public virtual GroupBuyType GroupBuyType { get; set; }

        public long? FloorId { get; set; }
        [ForeignKey(nameof(FloorId))]
        public virtual Floor Floor { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        [ForeignKey(nameof(CreatorUserId))]
        public virtual User Creator { get; set; }
        /// <summary>
        /// 成团人数
        /// </summary>
        public int NeedCount { get; set; }
        /// <summary>
        /// 当前参团人数
        /// </summary>
        public int CurrentCount { get; set; }
        /// <summary>
        /// 团长获利
        /// </summary>
        public int ChiefProfit { get; set; }
        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime EndDate { get; set; }
        /// <summary>
        /// 拼团状态
        /// </summary>
        public GroupState State { get; set; }
        /// <summary>
        /// 意向小区
        /// </summary>
        [StringLength(32)]
        public string WantVillage { get; set; }
        /// <summary>
        /// 意向楼层
        /// </summary>
        [StringLength(32)]
        public string WantLayer { get; set; }
        /// <summary>
        /// 意向户型
        /// </summary>
        [StringLength(32)]
        public string WantLayout { get; set; }
        /// <summary>
        /// 联系人
        /// </summary>
        [StringLength(32)]
        public string LinkMan { get; set; }
        /// <summary>
        /// 联系电话
        /// </summary>
        [StringLength(32)]
        public string PhoneNumber { get; set; }

        public virtual ICollection<GroupItem> GroupItems { get; set; }
        /// <summary>
        /// 是否通过审核
        /// </summary>
        public bool IsActive { get; set; }
    }
    public enum GroupState
    {
        [Description("进行中")]
        OnGoing,
        [Description("成功")]
        Succeed,
        [Description("失败")]
        Failed
    }
}
